export default {
	namespaced: true,
	actions:{
		
	},
	mutations:{
		// 获取收获地址信息
		getUserAdress(state,res){
			state.addressData = res;
			this.commit('m_user/localUserAdress');
		},
		
		// 将收货地址进行本地存储
		localUserAdress(state){
			uni.setStorageSync('local_adress', JSON.stringify(state.addressData))
		},
		
		// 获取用户的详情信息
		getUserDetails(state,userInfo){
			state.userInfo = userInfo;
			this.commit('m_user/localUserInfo');
		},
		
		// 将用户信息进行本地存储
		localUserInfo(state){
			uni.setStorageSync('local_userinfo', JSON.stringify(state.userInfo))
		},
		
		// 获取用户的token值
		getUserToken(state,token){
			state.token = token;
			this.commit('m_user/localToken');
		},
		
		// 将token值进行本地存储
		localToken(state){
			uni.setStorageSync('local_token',JSON.stringify(state.token))
		}
	},
	state:{
		// 地址数据
		addressData: JSON.parse(uni.getStorageSync('local_adress') || '{}'),
		token: uni.getStorageSync('local_token') || '',
		userInfo: JSON.parse(uni.getStorageSync('local_userinfo') || '{}')
	},
	getters:{
		// 地址信息进行拼接
		fullAdress(state){
			if(!state.addressData.provinceName) return ''
			return state.addressData.provinceName + state.addressData.cityName + state.addressData.countyName + state.addressData.detailInfo;
		}
	}
}